<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Class: Sass::Selector::Element</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '../..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (E)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span> &raquo; <span class='title'><a href="Selector.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector.html" title="Sass::Selector (module)">Selector</a></span>
     &raquo; 
    <span class="title">Element</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/Selector/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/Selector/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Sass::Selector::Element 
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName"><a href="Simple.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html" title="Sass::Selector::Simple (class)">Simple</a></span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next"><a href="Simple.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html" title="Sass::Selector::Simple (class)">Simple</a></li>
          
            <li class="next">Sass::Selector::Element</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">/var/www/sass-pages/.sass/lib/sass/selector.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>An element selector (e.g. <code>h1</code>).</p>

  </div>
</div>
<div class="tags">
  
</div>

  
  
  
  
  <h2>Instance Attribute Summary</h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#name-instance_method" title="#name (instance method)">- (Array&lt;String, Sass::Script::Node&gt;) <strong>name</strong> </a>
    

    
  </span>
  
  
    <span class="note title readonly">readonly</span>
    
  
  
  
  

  
    <span class="summary_desc">The element name.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#namespace-instance_method" title="#namespace (instance method)">- (Array&lt;String, Sass::Script::Node&gt;<sup>?</sup>) <strong>namespace</strong> </a>
    

    
  </span>
  
  
    <span class="note title readonly">readonly</span>
    
  
  
  
  

  
    <span class="summary_desc">The selector namespace.</span>
  
</li>

    
  </ul>


  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (Element) <strong>initialize</strong>(name, namespace) </a>
    

    
  </span>
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  

  
    <span class="summary_desc">A new instance of Element.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#specificity-instance_method" title="#specificity (instance method)">- <strong>specificity</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc"></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_a-instance_method" title="#to_a (instance method)">- <strong>to_a</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc"></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#unify-instance_method" title="#unify (instance method)">- <strong>unify</strong>(sels) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Unification of an element selector is somewhat complicated, especially when a namespace is specified.</span>
  
</li>

    
  </ul>

  
  
  
  
  
  <h3 class="inherited">Methods inherited from <a href="Simple.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html" title="Sass::Selector::Simple (class)">Simple</a></h3>
  <p class="inherited"><a href="Simple.html#eql%3F-instance_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html#eql%3F-instance_method" title="Sass::Selector::Simple#eql? (method)">#eql?</a>, <a href="Simple.html#hash-instance_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html#hash-instance_method" title="Sass::Selector::Simple#hash (method)">#hash</a>, <a href="Simple.html#inspect-instance_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html#inspect-instance_method" title="Sass::Selector::Simple#inspect (method)">#inspect</a>, <a href="Simple.html#to_s-instance_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html#to_s-instance_method" title="Sass::Selector::Simple#to_s (method)">#to_s</a>, <a href="Simple.html#unify_namespaces-instance_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html#unify_namespaces-instance_method" title="Sass::Selector::Simple#unify_namespaces (method)">#unify_namespaces</a></p>
<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <p class="signature first" id="initialize-instance_method">
  
    - (<tt><a href="" title="Sass::Selector::Element (class)">Element</a></tt>) <strong>initialize</strong>(name, namespace) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>A new instance of Element</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;String, <a href="Node-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Node.html" title="Sass::Script::Node (class)">Sass::Script::Node</a>&gt;</tt>)</span>
      
      
        <span class='name'>name</span>
      
      
      
        &mdash;
        The element name
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Array&lt;String, <a href="Node-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Node.html" title="Sass::Script::Node (class)">Sass::Script::Node</a>&gt;</tt>, <tt>nil</tt>)</span>
      
      
        <span class='name'>namespace</span>
      
      
      
        &mdash;
        See <tt><a href="#namespace-instance_method" title="Sass::Selector::Element#namespace (method)">#namespace</a></tt>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


211
212
213
214</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 211</span>

def initialize(name, namespace)
  @name = name
  @namespace = namespace
end</pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id=""></span>
      <span id="name-instance_method"></span>
      <div class="method_details first">
  <p class="signature first" id="name-instance_method">
  
    - (<tt>Array&lt;String, <a href="Node-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Node.html" title="Sass::Script::Node (class)">Sass::Script::Node</a>&gt;</tt>) <strong>name</strong>  <span class="extras">(readonly)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>The element name.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;String, <a href="Node-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Node.html" title="Sass::Script::Node (class)">Sass::Script::Node</a>&gt;</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


199
200
201</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 199</span>

def name
  @name
end</pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id=""></span>
      <span id="namespace-instance_method"></span>
      <div class="method_details ">
  <p class="signature " id="namespace-instance_method">
  
    - (<tt>Array&lt;String, <a href="Node-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Node.html" title="Sass::Script::Node (class)">Sass::Script::Node</a>&gt;</tt><sup>?</sup>) <strong>namespace</strong>  <span class="extras">(readonly)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>The selector namespace. <code>nil</code> means the default namespace, <code>[&quot;&quot;]</code> means no namespace, <code>[&quot;*&quot;]</code> means any namespace.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Array&lt;String, <a href="Node-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Node.html" title="Sass::Script::Node (class)">Sass::Script::Node</a>&gt;</tt>, <tt>nil</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


207
208
209</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 207</span>

def namespace
  @namespace
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="specificity-instance_method">
  
    - <strong>specificity</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
  <h3>See Also:</h3>
  <ul class="see">
    
      <li><a href="AbstractSequence.html#specificity-instance_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/AbstractSequence.html#specificity-instance_method" title="Sass::Selector::AbstractSequence#specificity (method)">AbstractSequence#specificity</a></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


256
257
258</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 256</span>

def specificity
  1
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="to_a-instance_method">
  
    - <strong>to_a</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
  <h3>See Also:</h3>
  <ul class="see">
    
      <li>Selector#to_a</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


217
218
219</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 217</span>

def to_a
  @namespace ? @namespace + ["|"] + @name : @name
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="unify-instance_method">
  
    - <strong>unify</strong>(sels) 
  

  
</p><div class="docstring">
  <div class="discussion">
    
  <p class="note todo">
    <strong>TODO:</strong> 
    There are lots of cases that this documentation specifies; make sure we thoroughly test <strong>all of them</strong>.
  </p>

  <p class="note todo">
    <strong>TODO:</strong> 
    Keep track of whether a default namespace has been declared and handle namespace-unspecified selectors accordingly.
  </p>

<p>Unification of an element selector is somewhat complicated, especially when a namespace is specified. First, if <code>sel</code> contains another <tt><a href="" title="Sass::Selector::Element (class)">Element</a></tt> with a different <tt><a href="#name-instance_method" title="Sass::Selector::Element#name (method)">#name</a></tt>, then the selectors can&#8217;t be unified and <code>nil</code> is returned.</p>

<p>Otherwise, if <code>sel</code> doesn&#8217;t specify a namespace, or it specifies any namespace (via <code>&quot;*&quot;</code>), then it&#8217;s returned with this element selector (e.g. <code>.foo</code> becomes <code>a.foo</code> or <code>svg|a.foo</code>). Similarly, if this selector doesn&#8217;t specify a namespace, the namespace from <code>sel</code> is used.</p>

<p>If both this selector <em>and</em> <code>sel</code> specify namespaces, those namespaces are unified via <tt><a href="Simple.html#unify_namespaces-instance_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/Selector/Simple.html#unify_namespaces-instance_method" title="Sass::Selector::Simple#unify_namespaces (method)">Simple#unify_namespaces</a></tt> and the unified namespace is used, if possible.</p>

  </div>
</div>
<div class="tags">
  
  <h3>See Also:</h3>
  <ul class="see">
    
      <li>Selector#unify</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


243
244
245
246
247
248
249
250
251
252
253</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/selector.rb', line 243</span>

def unify(sels)
  case sels.first
  when Universal;
  when Element; return unless name == sels.first.name
  else return [self] + sels
  end

  ns, accept = unify_namespaces(namespace, sels.first.namespace)
  return unless accept
  [Element.new(name, ns)] + sels[1..-1]
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:33:39 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>